import java.awt.*;

/**
 * @author Kiteye
 * @date 2023/7/3
 * @Description  理解 IoC
 */

public class CarDemo {
    public static void main(String[] args) {
        Tire tire = new Tire(40);
        Bottom bottom = new Bottom(tire);
        Framework framework = new Framework(bottom);
        Car car = new Car(framework);
        car.run();
    }

    /**
     * 汽车对象
     */
    static class Car {
        private Framework framework;
        public Car (Framework framework) {
            this.framework = framework;
        }
        public void run() {
            framework.run();
        }
    }

    /**
     * 车身类
     */
    static class Framework {
        public Bottom bottom;
        public Framework (Bottom bottom) {
            this.bottom = bottom;
        }
        public void run() {
            bottom.run();
        }
    }

    /**
     * 底盘类
     */
    static class Bottom {
        private Tire tire;
        public Bottom (Tire tire) {
            this.tire = tire;
        }

        public void run() {
            tire.run();
        }
    }

    /**
     * 轮胎类
     */
    static class Tire {
        // 尺寸
        private int size;
        public Tire(int size) {
            this.size = size;
        }
        public void run() {
            System.out.println("轮胎尺寸:"+ size);
        }
    }
}
